import { I18nContext } from 'nestjs-i18n'
import { I18nFactory } from './factory'
import { I18nFileJsonLoader } from './loader/i18n-file-json.loader'

const t: I18nContext['t'] = (key, options) => {
  if (I18nContext.current()) {
    return I18nContext.current().service.t(key, { lang: I18nContext.current().lang, ...options })
  }
  return (I18nContext.current()?.service ?? I18nFactory.getInstance())?.t(key, options)
}

export { I18nFactory, I18nFileJsonLoader }
export * from './validation'
export default { t }
